<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org" th:with="title='博客首页',active='blogpublish',hasEditor=false"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<!-- head 头部-->
<head th:replace="web/common/fragment::head(${title},null,'')"></head>
	<body>

		<div th:replace="web/layout/header::header(${active})"></div>
		<!--	main	-->
		<div class="fly-main">
			<div class="layui-row layui-col-space20">
				<div class="post-list-left layui-col-md9">
					<div class="blog-list clear" th:if="${not #lists.isEmpty(blogs)}">
						<div class="post-list-box" th:each="blog:${blogs}">
							<!--标题-->
							<h1 class="title">
								<a th:href="'/blog/'+${blog.blogId}" th:text="${blog.blogTitle}">这里是博客标题</a>
								<span class="javabb-mark javabb-top" th:if="${blog.blogTop}">顶</span>
								<span class="javabb-mark javabb-commend" th:if="${blog.blogSupport}">荐</span>
							</h1>
                            <!--<div class="tiezi-title">
                                <h1 class="title">
                                    <a th:href="'/blog/'+${blog.typeId}+'/'+${blog.blogId}" target="_blank" th:text="${blog.blogTitle}">这里是博客标题</a>
                                    <span class="javabb-mark javabb-top" th:if="${blog.blogTop}">顶</span>
                                    <span class="javabb-mark javabb-commend" th:if="${blog.blogSupport}">荐</span>
                                </h1>
                                <span class="do">
                                    <i class="layui-icon layui-icon-down"></i>
                                    <div class="tiezi-setting">
                                        <li th:onclick="|doAccusation(${blog.blogId})|">举报</li>
                                    </div>
                                </span>
                            </div>-->
							<!--内容-->
							<div class="post-list-content">
								<th:block th:if="${#strings.isEmpty(coverImage)}">
									<div class="post-list-content-text">
										<a th:href="'/blog/'+${blog.blogId}">
											<th:block th:text="${blog.blogDesc}">
												听说昨天，美参议院通过了香港人权与民主法案，这是值得深入思考的一件事。为什么美国用他们的合法化建立了一项干涉中国内政的非法法案？美参议院都是傻鸟吗？他们难道不怕我们中国政府的强烈谴责？实话实说，他们怕...
											</th:block>
										</a>
									</div>
									<div class="post-list-content-thum" th:if="${not #lists.isEmpty(blog.thumImages)}">
										<a th:each="thumImage:${blog.thumImages}" th:href="'/blog/'+${blog.blogId}" th:style="'background-image:url('+${thumImage}+');'" class="opacity"></a>
									</div>
									<!--附加信息-->
									<div class="post-info">
										<li class="author">
											<a th:href="'/user/'+${blog.author.id}">
												<img th:src="${thUtil.formatUserImage(blog.author.userImg)}" class="avatar opacity" width="40" height="40" th:alt="${blog.author.nickName}">
												<i class="javabb-verify javabb-verify-b" title="官方认证"></i>
												<span></span>
											</a>
											<a th:href="'/user/'+${blog.author.id}" th:text="${blog.author.nickName}">unknow</a>
										</li>
										<div th:include="web/view/blog/template::post-count-info(${blog})"></div>
									</div>
								</th:block>
								<th:block th:if="${not #strings.isEmpty(coverImage)}">
									<div class="post-list-content-left">
										<a th:href="${blog.coverImage}" th:style="'background-image:url('+${blog.coverImage}+');'" class="opacity"></a>
									</div>
									<div class="post-list-content-right">
										<div class="post-list-content-text">
											<a th:href="'/blog/'+${blog.blogId}" th:text="${blog.blogDesc}">
											    内容
                                            </a>
										</div>
										<!--附加信息-->
										<div class="post-info">
                                            <li class="author">
                                                <a th:href="'/user/'+${blog.author.id}">
                                                    <img th:src="${thUtil.formatUserImage(blog.author.userImg)}" class="avatar opacity" width="40" height="40" th:alt="${blog.author.nickName}">
                                                    <i class="javabb-verify javabb-verify-b" title="官方认证"></i>
                                                    <span></span>
                                                </a>
                                                <a th:href="'/user/'+${blog.author.id}" th:text="${blog.author.nickName}">unknow</a>
                                            </li>
											<div th:include="web/view/blog/template::post-count-info(${blog})"></div>

										</div>
									</div>
								</th:block>
							</div>
							<div class="post-footer">
								<span th:title="${blog.createTime}" th:text="${#dates.format(blog.createTime, 'yyyy-MM-dd HH:mm:ss')}">2019-11-02 21:14:44</span>
								<span>电脑端</span>
							</div>
						</div>
					</div>
					<div class="fly-none" th:if="${#lists.isEmpty(blogs)}">暂时还没有博客</div>
                    <ul class="pagination" th:utext="${pagination}"></ul>
				</div>
                <div class="post-list-right layui-col-md3">
					<!--归档-->
                    <div th:replace="web/view/blog/template::classify-sidebar"></div>
					<!--分类-->
					<div th:replace="web/view/blog/template::archive-sidebar"></div>
                </div>
			</div>
		</div>
		<!--	contianer end	-->
<!--	底部版权		-->
<div th:replace="web/layout/footer::footer"></div>
<!--	搜索		-->
<div th:replace="web/layout/common::pop-search"></div>
<!--	右边工具栏	-->
<div th:replace="web/layout/common::right-bar"></div>
<!--	引入JS	-->
<div th:replace="web/common/fragment::js" ></div>

<script type="text/javascript">
    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor',{
        toolbars:[[
            'paragraph','bold','italic','fontsize','fontborder','forecolor','backcolor','|','anchor','link','|','lineheight',
            'indent','justifyleft','justifycenter','|','insertcode','insertimage','fullscreen', //全屏
        ]
        ],
        textarea:'content'
    });

</script>
<script th:inline="javascript">
    layui.use('form', function(){
        var form = layui.form;
        var $ = layui.jquery;
        // 初始化是评论状态

        // 表单提交事件
        form.on('submit(publishSubmit)', function (data) {
        	//校验表单
        	checkForm(data);
            
            console.info(data.field);
            data.field.catalogId = catalogId;
            data.field.commentState = data.field.commentState==1?'1':'0';
            //data.field.parentId = data.field.parentId==null?'0':data.field.parentId;
            // 表单提交事件
            B.post({
                url: '/blog/publish/',
                loading: true,
                data: data.field,
                success: function (data) {
                    if (data.success) {
                        B.info(data.msg);
                        window.location.href="/blog/";
                    } else {
                        B.error(data.msg);
                    }
                }
            });
            
            return false;
        });
        function checkForm(data){
        	if(B.isEmpty(data.field.postTitle)){
        		B.error("标题不能为空");
        		return;
        	}
        	if(B.isEmpty(data.field.content)){
        		B.error("内容不能为空");
        		return;
        	}
        }
    })
</script>
	</body>
</html>
